var todolist = [];
var deletelist = [];

//实现了菜单里面对应功能的调用
$("li").click(function(){
    var id = $(this).attr("id");
    // alert(id);
    switch(id){
        case "1": setclock();break;
        case "2": switchtime();break;
        case "3": switch1();break;
    }
})

function addtodo(){
    var todo = document.getElementById("todoinput");
    var todotext = todo.value;
    if (todotext == ""){
        alert("输入内容不能为空")
        return ;
    }
    todolist.push(todotext);
    showtodo();
    todo.value = "";
    // alert(todolist);
}

//显示待办事项列表
function showtodo(){
    var html = "";
    for(var i = 0; i < todolist.length; i++){
        html +="<div class='todo'>" +
                    "<input type='checkbox' id='todo"+i+"' onclick='deletetodo(+"+i+")'>"+
                    "<p>"+todolist[i]+"</p>"+
                "</div>";
        
        // console.log(clocklist[i]);
    }
    for(var i = 0; i < deletelist.length; i++){
        html +="<div class='todo'>" +
                    "<input type='checkbox' checked='true' id='delete"+i+"' onclick='addtodo2(+"+i+")'>"+
                    "<p><s>"+deletelist[i]+"</s></p>"+
                "</div>";
        
        // console.log(clocklist[i]);
    }
    $("#todolist").html(html);
}

function deletetodo(n){
    var deletestr = todolist.splice(n,1);
    deletelist.push(deletestr);
    showtodo();
}

function addtodo2(n){
    var deletestr = deletelist.splice(n,1);
    todolist.push(deletestr);
    showtodo();
}